<script setup>
  import { ref } from 'vue';
  import { useRouter } from 'vue-router';

  let username = ref('')
  let password = ref('')
  const router = useRouter()

  function login(){
    if(username.value == 'root' & password.value == '123'){ 
      window.sessionStorage.setItem('username', username.value)
      router.push('/home')
    }else{
      alert('用户名或密码错误')
    }
  }
</script>

<template>
  <div>
    账号：<input type="text" v-model="username" ><br>
    密码：<input type="text" v-model="password" ><br>
    <button @click="login()">登录</button>
    <button>退出登录</button>
  </div>
  
</template>

<style scoped>

</style>
